package com.cuit.jifver.weibo.activity;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.cuit.jifver.weibo.data.Weibo;
import com.cuit.jifver.weibo.model.TextMessage;

public class MainListAct extends Activity implements OnClickListener
{
	Weibo weibo = Weibo.getInstance();
	private EditText editText;
	private Button button;
	private TextView textView;
	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main_list_act);
		editText = (EditText) findViewById(R.id.content_ed);
		textView = (TextView) findViewById(R.id.result_tv);
		button = (Button) findViewById(R.id.submit_btn);
		
		button.setOnClickListener(this);
	}
	@Override
	public void onClick(View v)
	{
		switch (v.getId())
		{
		case R.id.submit_btn:
			String content = editText.getText().toString();
			if (!content.trim().equals("")) 
			{
				TextMessage message = new TextMessage(content);
				String result = weibo.getMyWeibo().publishTextMessage(this, message);
				textView.setText(result);
			}
			
			break;

		default:
			break;
		}
		
	}

}
